'''
迭代
'''
def feibo(num):
    if num <= 0:
        print("输入的数小于1")
        return
    f = [1,1]
    if(num == 1 or num == 2):
        return f[num-1]
    for i in range(2,num+1):
        f.append(f[i-1]+f[i-2])
    return f[num-1]
'''
动态规划
'''
def feibo2(num):
    if num <= 0:
        print("输入的数小于1")
        return
    dp = [1] * (num+1)
    if(num == 1 or num == 2):
        return dp[num-1]
    for i in range(2,num+1):
        dp[i] = dp[i-1]+dp[i-2]
    return dp[num-1]
'''
生成器
'''
def feibo3(num):
    a,b = 1,1
    for _ in range(num):
        yield a
        a,b = b,a+b

#示例[1,1,2,3,5,8,13,21,34,45,79]
print("请输入要找第几个斐波那契")
n = int(input())
print(feibo(n),end = '\t')
print(feibo2(n),end = '\t')

gen = feibo3(n) #输出整个斐波那契数列
for i in gen:
    print(i,end ='\t')






